﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:controlsPrimitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone.Controls"
	xmlns:Controls="clr-namespace:Kiva7.Controls">

    <ControlTemplate x:Key="PivotControlTemplateLandscape" TargetType="Controls:OrientedPivot">
        <Grid x:Name="pivotGrid"
            HorizontalAlignment="{TemplateBinding HorizontalAlignment}" 
			VerticalAlignment="{TemplateBinding VerticalAlignment}">
            
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="cd1" Width="80"/>
                <ColumnDefinition x:Name="cd2" Width="*"/>
                <ColumnDefinition x:Name="cd3" Width="0"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <Grid x:Name="pivotBackground"
				Grid.RowSpan="3" 
                Grid.ColumnSpan="3" 
				Background="{TemplateBinding Background}" 
				CacheMode="BitmapCache"/>

            <ContentPresenter Visibility="Collapsed"
                              x:Name="pivotTitle"
                              Grid.RowSpan="1" 
                              Grid.Row="0"
                              Grid.Column="0"
                              Grid.ColumnSpan="3"
					Content="{TemplateBinding Title}"
					Margin="24,17,0,-7"
					ContentTemplate="{TemplateBinding TitleTemplate}"/>

            <ItemsPresenter
				Grid.Column="1"
                Grid.ColumnSpan="1"
                Grid.Row="0"
                Grid.RowSpan="3" 
				Margin="{TemplateBinding Padding}"
				x:Name="PivotItemPresenter"/>

            <Grid x:Name="HeadersListGrid"
                  Grid.Column="0"
                  Grid.ColumnSpan="1"
                  Grid.Row="0"
                  Grid.RowSpan="3" 
                  VerticalAlignment="Bottom">
                <Grid.Projection>
                    <PlaneProjection x:Name="pivotPlaneProjection" RotationZ="90" />
                </Grid.Projection>
                <TextBlock Text=" "/>
                <controlsPrimitives:PivotHeadersControl
				x:Name="HeadersListElement">
                </controlsPrimitives:PivotHeadersControl>
            </Grid>

        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="PivotControlTemplatePortrait" TargetType="Controls:OrientedPivot">
        <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" 
				VerticalAlignment="{TemplateBinding VerticalAlignment}">

            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="cd1" Width="80"/>
                <ColumnDefinition x:Name="cd2" Width="*"/>
                <ColumnDefinition x:Name="cd3" Width="0"/>
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <Grid Grid.ColumnSpan="3"
					Grid.RowSpan="3" 
					Background="{TemplateBinding Background}" 
					CacheMode="BitmapCache"/>

            <ContentPresenter Grid.ColumnSpan="3"
					Content="{TemplateBinding Title}"
					Margin="24,17,0,-7"
					ContentTemplate="{TemplateBinding TitleTemplate}"/>

            <ItemsPresenter
                    Grid.ColumnSpan="3"
					Grid.Row="2"
					Margin="{TemplateBinding Padding}"
					x:Name="PivotItemPresenter"/>

            <Grid x:Name="HeadersListGrid"
                  Grid.ColumnSpan="3"
                  Grid.Row="1"
                  VerticalAlignment="Bottom">

                <TextBlock Text=" "/>
                <controlsPrimitives:PivotHeadersControl
				x:Name="HeadersListElement">
                </controlsPrimitives:PivotHeadersControl>
            </Grid>

        </Grid>
    </ControlTemplate>

    <Style TargetType="Controls:OrientedPivot">
        <Setter Property="Template" Value="{StaticResource PivotControlTemplateLandscape}"/>
        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="{Binding}" Foreground="#FF74B446" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>